package com.mikey.springcloud.service.impl;

import com.mikey.springcloud.pojo.Category;
import com.mikey.springcloud.mapper.CategoryMapper;
import com.mikey.springcloud.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author :Mikey
 * @description :
 * @create :2022-08-29 19:06:00
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;
    public int insert(Category category) {
        return categoryMapper.insert(category);
    }

    public int delete(Integer id) {
        return categoryMapper.delete(id);
    }

    public int update(Category category) {
        return categoryMapper.update(category);
    }

    public Category selectOne(Integer id) {
        return categoryMapper.selectOne(id);
    }

    public List<Category> selectAll() {
        List<Category> list =new ArrayList<Category>();
        List<Category> categories = categoryMapper.selectAll();
        for (Category category : categories) {
            category.setProvider("8091");
            list.add(category);
        }
        return list;
    }
}
